<template>
  <div class="echarts-box">
    <div id="myEcharts" style="height: 300px; width: 1000px"></div>
  </div>
  <el-table
    :data="tableData"
    stripe
    style="width: 100%"
    :header-cell-style="{ 'border-bottom': 'none' }"
    :header-row-style="{ height: '60px' }"
    :cell-style="{ height: '60px', 'border-bottom': 'none' }"
  >
    <el-table-column prop="date" label="分数" />
    <el-table-column prop="name" label="位次" />
    <el-table-column prop="name" label="科类" />
    <el-table-column prop="name" label="创建时间" />
    <el-table-column prop="name" label="志愿表" />
  </el-table>
</template>

<script>
import * as echarts from 'echarts';
export default {
  name: 'App',
  props: ['width', 'height'],
  setup() {
    let myEcharts = echarts;
    const tableData = [
      {
        date: '2016-05-03',
        name: 'Tom',
      },
      {
        date: '2016-05-03',
        name: 'Tom',
      },
      {
        date: '2016-05-03',
        name: 'Tom',
      },
      {
        date: '2016-05-03',
        name: 'Tom',
      },
    ];

    function initChart() {
      let chart = myEcharts.init(
        document.getElementById('myEcharts'),
        'purple-passion'
      );
      chart.setOption({
        xAxis: {
          type: 'category',
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
        },
        yAxis: {
          type: 'value',
        },
        series: [
          {
            data: [150, 230, 224, 218, 135, 147, 260],
            type: 'line',
          },
        ],
      });
      window.onresize = function () {
        chart.resize();
      };
    }

    return {
      initChart,
      tableData,
    };
  },
};
</script>
